package sw6.admin.parser;

import android.content.Context;
import sw6.admin.database.DatabaseHelper;

/**
 * 
 * @author sw6b
 */
public class ResetSettings implements ISettingsParserInjection {

	private DatabaseHelper db;
	private String appName;
	
	@Override
	public void init(Context context, String appName) {
		this.db = new DatabaseHelper(context);
		this.appName = appName;
	}

	@Override
	public void handleInteger(String varName, int min, int max, int varValue) {
		db.updateInteger(appName, varName, varValue);
	}

	@Override
	public void handleDouble(String varName, double min, double max, double varValue) {
		db.updateDouble(appName, varName, varValue);
	}

	@Override
	public void handleBoolean(String varName, boolean varValue) {
		db.updateBoolean(appName, varName, varValue);
	}

	@Override
	public void handleString(String varName, int min, int max, String varValue) {
		db.updateString(appName, varName, varValue);
	}

	@Override
	public void handleObject(String varName, String type, byte[] varValue) {
		db.updateObject(appName, varName, type, varValue);
	}

	@Override
	public void handleEnumElement(String varName, int varValue) {
		/**
		 * Since we can't change the enum elements there are already been
		 * added to the database we just ignore any input here.
		 */
		return;
	}

	@Override
	public void handleEnum(String varName, int varValue) {
		db.updateEnum(appName, varName, varValue);
	}
	
	@Override
	public void end() {
		db.close();
	}
	
}
